BUILDER R Functions

reserve_seeds()

The reserve_seeds() function creates a seeds table based on conservation areas, which is an input to builder().
It identifies seed catchments inside a conservation area and assigns them an area target.

Seed catchments are the starting points for constructing benchmarks.
This function provides methods for filtering the catchments dataset and assigning area targets.

Usage

reserve_seeds(
  catchments_sf,
  CAs_sf,
  CAs_id = NULL,
  areatarget_value = NULL,
  joinType = NULL
)

Arguments

  • catchments_sf: sf object of the catchments dataset with a unique identifier column: CATCHNUM.

  • CAs_sf: A character string. Name of the column holding conservation area unique identifiers.

  • CAs_id: A character string. Name of the column holding conservation area unique identifiers.

  • areatarget_value: (Optional) A single numeric value specifying the area target to apply to all seeds.

  • joinType: A character string. Type of spatial join to identify catchments within conservation areas. Options are "INTERSECT" or "CENTROID". Default is "CENTROID".

📤 Output

A tibble of reserve seed catchments and their associated area targets.

Examples

Running the examples

  1. Download and unzip BEACONs R Tools

  2. Create the folder structure

# Set working directory
setwd("your/path/to/downloads")

dirpath <- getwd()

# Create the folder structure
treedir <- c("R","data","Builder_input")
for(d in treedir){
  if (!dir.exists(file.path(dirpath, d))) {
    dir.create(file.path(dirpath, d), recursive = TRUE)
  }
}
  1. Run the examples below.
library(dplyr)
library(sf)
library(utils)

source("./R/builder.R")

# Use all catchments as seeds with a single area target
catchments_sample <- readRDS("data/catchments_sample.rds")
reserves_sample <- readRDS("data/reserves_sample.rds")
reserve_seeds(catchments_sf = catchments_sample, CAs_sf = reserves_sample, CAs_id = "reserve", areatarget_value = 1000000000)

# save seeds as csv
reserve_seed <- reserve_seeds(catchments_sf = catchments_sample, CAs_sf = reserves_sample, CAs_id = "reserve", areatarget_value = 1000000000)
write.csv(reserve_seed, file=file.path(dirpath,"Builder_input/reserve_seeds.csv"), na = "", row.names=FALSE)